year, month = map(int, input().strip().split(' '))
def is_leap(y):
    if y % 4 == 0:
        if y % 100 == 0:
            if y % 400 == 0:
                return True
            else:
                return False
        else:
            return True
    else:
        return False

if month in {1, 3, 5, 7, 8, 10, 12}:
    print(31)
elif month == 2:
    if is_leap(year):
        print(29)
    else:
        print(28)
else:
    print(30)
